<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function p1() {
      return new Promise(resolve => {
        setTimeout(() => {
          resolve('p1')
        }, 1000)
      })
    }
    function p2() {
      return new Promise(resolve => {
        setTimeout(() => {
          resolve('p2')
        }, 1000)
      })
    }

    async function fn() {
      // let h1 = await p1()
      // console.log(h1)
      // let h2 = await p2()
      // console.log(h2)

      // let h1 = p1()
      // let h2 = p2()
      // setTimeout(() => {
      //   console.log(h1, h2)
      // }, 1000)
      // let h1value = await h1; // then
      // let h2value = await h2;
      // console.log(h1value, h2value)

      let res = await Promise.all([p1(), p2()])
      console.log(res)
    }
    fn()
  </script>
</body>
</html>